package com.ulife.supplier.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ulife.supplier.dao.SupplierDao;
import com.ulife.supplier.dao.dataobject.SupplierDo;

/**
 * 供应商
 * 
 * @author Administrator
 */
public class SupplierDaoImpl extends SqlMapClientDaoSupport implements SupplierDao {
	public void insertSupplier(SupplierDo supplierDo) throws SQLException {
		this.getSqlMapClientTemplate().insert("Supplier.insertSupplier", supplierDo);
	}

	public int updateSupplier(SupplierDo supplierDo) throws SQLException {
		return this.getSqlMapClientTemplate().update("Supplier.updateSupplier", supplierDo);
	}

	public int deleteSupplier(Long sId) throws SQLException {
		SupplierDo supplierDo = new SupplierDo();
		supplierDo.setsId(sId);
		supplierDo.setsStatus(0);
		return this.getSqlMapClientTemplate().update("Supplier.updateSupplier", supplierDo);
	}

	@SuppressWarnings("unchecked")
	public List<SupplierDo> queryAllSupplier() throws SQLException {
		return (List<SupplierDo>) this.getSqlMapClientTemplate().queryForList("Supplier.queryAllSupplier");
	}
	
	public SupplierDo querySupplierById(Long sId) throws SQLException {
		return (SupplierDo) this.getSqlMapClientTemplate().queryForObject("Supplier.querySupplierById",sId);
	}

	@SuppressWarnings("unchecked")
	public List<SupplierDo> querySupplier(SupplierDo supplierDo) throws SQLException {
		return (List<SupplierDo>) this.getSqlMapClientTemplate().queryForList("Supplier.querySupplier", supplierDo);
	}
}
